package org.example.ch03.p01;
import java.util.Scanner;

class Person {
    private static int count = 0;
    private String name;
    private boolean gender;
    private int age;
    private int id;

    static {
        System.out.println("This is static initialization block");
    }

    {
        id = count++;
        System.out.println("This is initialization block, id is " + id);
    }

    public Person() {
        System.out.println("This is constructor");
    }

    public Person(String name, boolean gender, int age) {
        this.name = name;
        this.gender = gender;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person [name=" + (name != null ? name : "null") +
                ", age=" + age +
                ", gender=" + (gender ? "true" : "false") +
                ", id=" + id + "]";
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine(); // 消耗换行符
        Person[] people = new Person[n];
        for (int i = 0; i < n; i++) {
            String name = scanner.next();
            int age = scanner.nextInt();
            boolean gender = scanner.nextBoolean();
            people[i] = new Person(name, gender, age);
        }
        for (int i = n - 1; i >= 0; i--) {
            System.out.println(people[i].toString());
        }
        Person p = new Person();
        System.out.println(p.toString());
        scanner.close();
    }
}